#!/bin/bash

#下载源
yum install epel-release -y

dockerfile="docker.repo"
#配置安装源
cd /etc/yum.repos.d/
#判断文件是否存在
if [ -f "$dockerfile" ]; then
　　rm -f "$dockerfile"
fi
touch $dockerfile
#编辑下载源
cp $dockerfile /etc/yum.repos.d/

yum install docker-engine -y

#安装docker-compose
curl -L https://get.daocloud.io/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose

#修改 /lib/systemd/system/docker.service
sed -i  's/ExecStart=\/usr\/bin\/dockerd/ExecStart=\/usr\/bin\/dockerd --storage-driver=devicemapper --registry-mirror=https:\/\/7rgqloza.mirror.aliyuncs.com --insecure-registry=harbor.mytijian.cn --insecure-registry=hub.mytijian.cn -H 0.0.0.0:2375 -H unix:\/\/\/var\/run\/docker.sock --pidfile=\/var\/run\/docker.pid/g'  /lib/systemd/system/docker.service
cd
